package com.woniuxy.yygh.msm.receiver;

import com.rabbitmq.client.Channel;
import com.woniuxy.common.rabbit.constant.MqConst;
import com.woniuxy.yygh.msm.service.MsmService;
import com.woniuxy.yygh.vo.msm.MsmVo;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * <P> @Author: ideaAdmin
 * <P> TODO: Class
 * <P> TODO: mq监听器 发送短信
 * <P> Date: 2022/3/6:11:39
 * <P> Description:
 */

@Component
public class SmsReceiver {
    @Resource
    private MsmService msmService;

    /**
     *
     * TODO 绑定对应的队列 交换机 路由名 短信对应
     *      durable = "true" 是否持久化
     */
    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = MqConst.QUEUE_MSM_ITEM, durable = "true"),
            exchange = @Exchange(value = MqConst.EXCHANGE_DIRECT_MSM),
            key = {MqConst.ROUTING_MSM_ITEM}
    ))
    public void send(MsmVo msmVo, Message message, Channel channel) {
        msmService.send(msmVo);
    }
}
